package com.zjl.quartz.第01章_基础的使用;

import com.zjl.springbatch.util.OutColour;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;

import java.time.LocalDateTime;

@DisallowConcurrentExecution//标记在 Job 类上，指示调度器不应在同一时刻并发执行同一个作业实例
@PersistJobDataAfterExecution//标记在 Job 类上，表示作业成功执行后，应将修改过的 JobDataMap 数据持久化保存
@Slf4j
public class E_Job implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        OutColour.out.printlnRed("次数：" + jobDataMap.getInt("count"));
        jobDataMap.put("count",jobDataMap.getInt("count")+1);
        // your logics
        log.info("E Demo Job执行时间: " + LocalDateTime.now());
    }
}
